﻿#ifndef __SS_REDIS_POOL_H__
#define __SS_REDIS_POOL_H__
#include "./ssRedisConnection.h"
#include "thread/threadLock/ssThreadLockGuard.h"
#include <list>
#include <vector>

namespace StarSeeker
{

class ssRedisPool
{
public:
	ssRedisPool();
	~ssRedisPool();
	//初始化连接
	void Init(const char *hostname, int port, unsigned int count);
	//等待结束，必须等到所有连接都归还后才会结束
	void WaitForExit();
	//获取连接
	ssRedisConnection* GetConnection();
	//归还连接
	void ReleaseConnection(ssRedisConnection* pConn);
private:
	std::list<ssRedisConnection*>	m_free;
	std::vector<ssRedisConnection*>	m_all;
	ssThreadLock					m_lock;
};

}
#endif
